/**
 * @description 作品内容 Model
 */

const mongoose = require('../db/mongoose')

// 两个 model 公用一个 schema
// content: { components: [{},{},{}], props: { backgroundColor: 'white }, setting: { shareImg: ''} }
const ContentSchema = new mongoose.Schema(
  {
    // 页面的组件列表
    components: [Object],
    // 页面的属性，如页面背景图片
    props: Object,
    // 配置信息，如微信分享配置
    setting: Object
  },
  {
    timestamps: true,
    toJSON: {
      transform(doc, ret) {
        delete ret.__v
      }
    }
  }
)

// 未发布的内容
const WorkContentModel = mongoose.model('work_content', ContentSchema)

// 发布的内容
const WorkPublishContentModel = mongoose.model('work_publish_content', ContentSchema)

module.exports = {
  WorkContentModel,
  WorkPublishContentModel
}
